package com.future.lock.mall.entity.response;

import com.future.lock.common.http.response.HttpResponse;
import com.future.lock.me.order.utils.JSONUtil;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.List;

/**
 * Created by yzh on 2017/9/20.
 */
public class BaseDataListResponse<T> extends HttpResponse {

    public List<T> dataSet;

    private final Class<T> clz;

    public BaseDataListResponse(Class<T> clz) {
        this.clz = clz;
    }

    @Override
    protected void parseData(String dataString) throws JSONException {
        try {
            dataSet = JSONUtil.parseJSONArray(new JSONArray(dataString), clz);
        }
        catch (Exception e) {
            e.printStackTrace();
            throw new JSONException(e.getMessage());
        }

    }
}
